        <script type="text/javascript">

            var req;
            var vid = false;
            var vname = false;
            var vemail = false;
            var vpass1 = false;
            var vpass2 = false;
            var vanswer = false;
            function validateid()
            {
                mdiv = document.getElementById("invalidID");
                var idField = document.getElementById("userid3");
                if(idField.value == '')
                    setMessage("invalid");

                var url = "registration_vertify.html?idajax=" + encodeURI(idField.value);

                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    req=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    req=new ActiveXObject("Microsoft.XMLHTTP");
                }
                req.open("GET", url, true);
                req.onreadystatechange = callbackforid;
                req.send(null);
            }

            function callbackforid()
            {
                if (req.readyState == 4)
                {
                    if (req.status == 200) {
                        parseMessage();
                    }

                }
            }

            function parseMessage()
            {
                var message = req.responseXML.getElementsByTagName("message")[0];
                setMessage(message.childNodes[0].nodeValue);
            }

            function setMessage(message) {
                mdiv = document.getElementById("invalidID");
                if (message == "invalid")
                {
                    mdiv.innerHTML = "<span style=\"color:red\"><br />User ID has to be at least 5 characters.</span>";
                    vid = false;
                }
                else if(message == "valid")
                {
                    mdiv.innerHTML = "<span style=\"color:green\">Valid User ID</span>";
                    vid = true;
                }
                else if(message == "duplicate")
                {
                    vid = false;
                    mdiv.innerHTML = "<span style=\"color:red\">User ID already exists</span>";
                }
            }

            function validatename()
            {

                var idField = document.getElementById("name");
                if(idField.value == '')
                    setMessageforname("invalid");

                var url = "registration_vertify.html?name=" + encodeURI(idField.value);

                if (typeof XMLHttpRequest != "undefined")
                {
                    req = new XMLHttpRequest();}
                else if (window.ActiveXObject) {
                    req = new ActiveXObject("Microsoft.XMLHTTP");
                }
                req.open("GET", url, true);
                req.onreadystatechange = callbackforname;
                req.send(null);
            }

            function callbackforname()
            {
                if (req.readyState == 4)
                {
                    if (req.status == 200) {
                        parseMessageforname();
                    }

                }
            }

            function parseMessageforname()
            {
                var message = req.responseXML.getElementsByTagName("message")[0];
                setMessageforname(message.childNodes[0].nodeValue);
            }

            function setMessageforname(message) {
                mdiv = document.getElementById("invalidname");
                if (message == "invalid")
                {
                    mdiv.innerHTML = "<span style=\"color:red\">Name has to be 5 characters and no numbers</span>";
                    vname = false;
                }
                else if(message == "valid")
                {
                    mdiv.innerHTML = "<span style=\"color:green\">Valid Name</span>";

                    vname = true;
                }
            }

            function validatepassword()
            {

                var idField = document.getElementById("password");
                if(idField.value == '')
                    setMessage("invalid");

                var url = "registration_vertify.html?password=" + encodeURI(idField.value);

                if (typeof XMLHttpRequest != "undefined")
                {
                    req = new XMLHttpRequest();}
                else if (window.ActiveXObject) {
                    req = new ActiveXObject("Microsoft.XMLHTTP");
                }
                req.open("GET", url, true);
                req.onreadystatechange = callbackforpassword;
                req.send(null);
            }

            function callbackforpassword()
            {
                if (req.readyState == 4)
                {
                    if (req.status == 200) {
                        parseMessageforpassword();
                    }

                }
            }

            function parseMessageforpassword()
            {
                var message = req.responseXML.getElementsByTagName("message")[0];
                setMessageforpassword(message.childNodes[0].nodeValue);
            }

            function setMessageforpassword(message) {

                if (message == "invalid")
                {
                    mdiv = document.getElementById("invalidpassword");
                    mdiv.innerHTML = "<span style=\"color:red\">Password bas to be 8 characters with both alphabet and number.</span>";
                    mdiv = document.getElementById("validpassword");
                    mdiv.innerHTML = "<span>&nbsp;</span>";
                    vpass1 = false;
                }
                else if(message == "valid")
                {
                    mdiv = document.getElementById("validpassword");
                    mdiv.innerHTML = "<span style=\"color:green\">Valid Password</span>";
                    mdiv = document.getElementById("invalidpassword");
                    mdiv.innerHTML = "<span>&nbsp;</span>";

                    vpass1 = true;
                }
            }

            function validatematch()
            {
                var pass1 = document.getElementById("password");
                var pass2 = document.getElementById("confirmpassword");

                if(pass1.value == pass2.value)
                {
                    mdiv = document.getElementById("matchpassword");
                    mdiv.innerHTML = "<span style=\"color:green\">Passwords matched</span>";

                    vpass2 = true;
                }
                else
                { vpass2 = false;
                    mdiv = document.getElementById("matchpassword");
                    mdiv.innerHTML = "<span style=\"color:red\">Passwords not matched</span>";
                }
            }

            function validateemail()
            {
                mdiv = document.getElementById("invalidemail");
                mdiv.innerHTML = "<span style=\"color:red\"><img src='images/logoicon.gif' width='20' alt='loading' /></span>";
                var idField = document.getElementById("email");

                if(idField.value == '')
                    setMessageforemail("invalid");

                var url = "registration_vertify.html?email=" + encodeURI(idField.value);

                if (typeof XMLHttpRequest != "undefined")
                {
                    req = new XMLHttpRequest();}
                else if (window.ActiveXObject) {
                    req = new ActiveXObject("Microsoft.XMLHTTP");
                }
                req.open("GET", url, true);
                req.onreadystatechange = callbackforemail;
                req.send(null);
            }

            function callbackforemail()
            {
                if (req.readyState == 4)
                {
                    if (req.status == 200) {

                        parseMessageforemail();
                    }

                }
            }

            function parseMessageforemail()
            {
                var message = req.responseXML.getElementsByTagName("message")[0];
                setMessageforemail(message.childNodes[0].nodeValue);
            }

            function setMessageforemail(message) {
                mdiv = document.getElementById("invalidemail");
                if (message == "invalid")
                {
                    mdiv.innerHTML = "<span style=\"color:red\">Invalid email address</span>";
                    vemail = false;
                }
                else if(message == "valid")
                {
                    mdiv.innerHTML = "<span style=\"color:green\">Valid email address</span>";
                    vemail = true;
                }

                else if(message == "duplicate")
                {
                    mdiv.innerHTML = "<span style=\"color:red\">Email address exists already</span>";
                    vemail = false;
                }
            }

            function validateanswer()
            {
                var answer = document.getElementById("answer");
                mdiv = document.getElementById("invalidanswer");

                if(answer.value.length < 1)
                {
                    mdiv.innerHTML = "<span style=\"color:red\">Invalid security answer.</span>";
                    vanswer = false;
                }
                else
                {

                    mdiv.innerHTML = "<span style=\"color:green\">Valid security answer.</span>";
                    vanswer = true;
                }
            }

        </script>
        <center><form id="form1" name="form1" method="post" action="submitinfo.html">
                <table width="790" class="table">
                    <tr>
                        <td align="center"><p><a href="index.jsp">Stock Market powered by XQL</a></p>
                            <hr /></td>
                    </tr>
                    <tr>
                        <td align="center" height="40">
                            <p>Please fill out the information to create an account.</p></td>
                    </tr>
                    <tr>
                        <td align="center">
                            <table width="100%">
                                <tr>
                                    <td width="200" rowspan="9"></td>
                                    <td align="left" width="150" >User ID</td>
                                    <td align="left">
                                            <input name="id" type="text" class="textBox" id="userid3" maxlength="10" value="" onchange="validateid()" /><span id="invalidID" class="invalidInput"></span></td>
                                </tr>
                                <tr>
                                    <td align="left">Password</td>
                                    <td align="left"><input name="password" type="password" class="textBox" id="password" maxlength="15" onchange="validatepassword()" />
                                        <span id="validpassword" class="invalidInput"></span></td>
                                </tr>
                                <tr><td></td><td align="left"><span class="invalidInput" id="invalidpassword">&nbsp;</span></td></tr>
                                <tr>
                                    <td align="left">Confirm Password</td>
                                    <td align="left"><input name="confirmpassword" type="password" class="textBox" id="confirmpassword" maxlength="15" onchange="validatematch()" />
                                        <span class="invalidInput" id="matchpassword"></span></td>
                                </tr>
                                <tr>
                                    <td align="left">Last Name</td>
                                    <td align="left">
                                        <input name="lastname" type="text" class="textBox" id="lastname" maxlength="20" value="" onchange="" />
                                        <span class="invalidInput" id="invalidname"></span></td>
                                </tr>
                                <tr>
                                    <td align="left">First Name</td>
                                    <td align="left">
                                        <input name="firstname" type="text" class="textBox" id="firstname" maxlength="20" value="" onchange="" />
                                        <span class="invalidInput" id="invalidname"></span></td>
                                </tr>
                                <tr>
                                    <td align="left">Phone Number</td>
                                    <td align="left">
                                        <input name="phone1" type="text" class="textBox" size="3" id="phone1" maxlength="3" value="" onchange="" />
                                        <input name="phone2" type="text" class="textBox" size="3" id="phone2" maxlength="3" value="" onchange="" />
                                        <input name="phone3" type="text" class="textBox" size="4" id="phone3" maxlength="4" value="" onchange="" />
                                    </td>
                                </tr> 

                                <tr>
                                    <td align="left">Email</td>
                                    <td align="left">
                                        <input name="email" type="text" class="textBox" id="email" maxlength="30" value="${requestScope.registrationUser.email}" onchange="validateemail()"/>
                                        <span id="invalidemail" class="invalidInput"></span></td>
                                </tr>
                                <tr>
                                    <td align="left">Social Security Number</td>
                                    <td align="left">
                                        <input name="ssn" type="text" class="textBox" id="ssn" maxlength="9" value="" onchange="" />
                                        <span class="invalidInput" id="invalidname"></span></td>
                                </tr>
                                        <tr><td></td>
                                    <td align="left">Credit Card</td>
                                    <td align="left">
                                        <input name="credit1" type="text" class="textBox" size="4" id="phone1" maxlength="4" value="" onchange="" />
                                        <input name="credit2" type="text" class="textBox" size="4" id="phone2" maxlength="4" value="" onchange="" />
                                        <input name="credit3" type="text" class="textBox" size="4" id="phone3" maxlength="4" value="" onchange="" />
                                        <input name="credit4" type="text" class="textBox" size="4" id="phone3" maxlength="4" value="" onchange="" />
                                   
                                </tr>
                                <tr><td></td>
                                    <td align="left">Address</td>
                                    <td align="left">
                                        <input name="address" type="text" class="textBox" id="address" maxlength="20" value="" onchange="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td align="left">Zip Code</td>
                                    <td align="left">
                                        <input name="zipcode" type="text" class="textBox" id="zipcode" maxlength="5" value="" onchange="" />
                                    </td>
                                </tr>
                                <tr><td>&nbsp;</td></tr>
                                <tr>
                                    <td align="center" colspan="4">By clicking on 'I accept' below you are agreeing to the Terms of Service and the Privacy Policy.</td>
                                </tr>
                                <tr><td>&nbsp;</td></tr>
                                <tr>
                                    <td align="center" colspan="4"><input  style="width:19em" name="save" type="submit" class="button" value="I accept. Create my account" onclick="this.form.onsubmit(); return false;this.disabled=true;" />
                                        <input name="cancel" type="submit" class="button" id="cancel" value="Cancel" /></td><td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table></form></center>
